#!/bin/bash

key="71776572747975696f706c6b6a686766"
iv="7a786376626e6d6c6b6a686766647361"

function fileEnc() {
        RAW_FILE=${1}
        ENC_FILE=${2}
        openssl enc -e -aes-128-cbc -K ${key} -iv ${iv} -in ${RAW_FILE} -out ${ENC_FILE}
}

function loadimg() {
        for file in $(ls $1); do
                if [ -d $1"/"$file ]; then
                        echo "error"
                else
                        fileEnc $1"/"$file $2"/"${file}.enc
                fi
        done
}

if test $# -lt 2; then
        echo "uage: script.sh src_path dst_path"
        exit 1
fi

src_path=$1
dst_path=$2

loadimg ${src_path} ${dst_path}
